package LeetCode.Hash;

import java.util.HashSet;
import java.util.Set;

/**
 * @author : LdLtd
 * @Date : 2023/7/24
 * @Description:771. 宝石与石头
 */
public class jewels_and_stones {
    public static void main(String[] args) {
        Solution solution = new Solution();
        String jewels = "aA", stones = "aAAbbbb";
        System.out.println(solution.numJewelsInStones(jewels, stones));
    }
    static class Solution {
        public int numJewelsInStones(String jewels, String stones) {
            int res=0;
            char[] chars = jewels.toCharArray();
            Set<Character> set = new HashSet<>();
            for (int i = 0; i < chars.length; i++) {
                set.add(chars[i]);
            }
            for (int i = 0; i < stones.length(); i++) {
                if(set.contains(stones.charAt(i)))
                    res+=1;
            }
            return res;

        }
    }
}
